package com.linwen.excise.base;

/**
 * @author : linwen
 * @date : 下午11:32 2021/5/24
 */
public class _05判断奇数 {
    public static void main(String[] args) {
        long count = 0;
        long count1 = 0;
        long start = System.currentTimeMillis();
        for (int i = 0; i <10000000 ; i++) {
            if(i%2==1){
                //System.out.println(i);
                count++;
            }
        }
        long end = System.currentTimeMillis();

        long start1 = System.currentTimeMillis();
        for (int i = 0; i <10000000 ; i++) {
            // 奇数二进制末尾都是1，与1与之后只能得1
            if((i&1)==1){
                //System.out.println(i);
                count1++;
            }
        }
        long end1 = System.currentTimeMillis();
        System.out.println("花费"+(end-start));
        System.out.println(count);
        System.out.println("花费"+(end1-start1));
        System.out.println(count1);
    }
}
